package com.leyou.item.client;

import com.leyou.common.domain.PageResult;
import com.leyou.item.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 *  @FeignClient里面指定调用的服务名称
 */
@FeignClient("item-service")
public interface ItemClient {

    /**
     * 查询出所有Spu对象的接口，以便于将所有的Spu对象转成Goods对象
     */
    /**
     * Spu分页查询
     * @return
     */
    @GetMapping("/spu/page")
    public PageResult<SpuDTO> spuPageQuery(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                           @RequestParam(value = "rows", defaultValue = "5") Integer rows,
                                           @RequestParam(value = "key", required = false) String key,
                                           @RequestParam(value = "saleable", required = false) Boolean saleable);

    /**
     * 根据spuId查询Sku集合
     */
    @GetMapping("/sku/of/spu")
    public List<SkuDTO> findSkusBySpuId(@RequestParam("id") Long id);

    /**
     * 根据spuId查询SpuDetail对象
     */
    @GetMapping("/spu/detail")
    public SpuDetailDTO findSpuDetailDTObyId(@RequestParam("id") Long id);

    /**
     * 查询规格参数
     * @param searching
     * @return
     */
    @GetMapping("/spec/params")
    public List<SpecParamDTO> findSpecParams(@RequestParam(value = "gid", required = false) Long gid,
                                                             @RequestParam(value = "cid", required = false) Long cid,
                                                             @RequestParam(value = "searching", required = false) Boolean searching);

    @GetMapping("/category/list")
    public List<CategoryDTO> findCategorysByCids(@RequestParam("ids") List<Long> ids);

    @GetMapping("/brand/{id}")
    public BrandDTO findBrandById(@PathVariable("id") Long id);

    @GetMapping("/spu/{id}")
    public SpuDTO findSpuById(@PathVariable("id") Long id);

    @GetMapping("/spec/of/category")
    public List<SpecGroupDTO> findSpecGroupAndParamByCid3(@RequestParam("id") Long id);

    @GetMapping("/sku/list")
    public List<SkuDTO> findSkusByIds(@RequestParam("ids") List<Long> ids);

    @PutMapping("/stock/minus")
    public Void minusStock(@RequestBody Map<Long, Integer> map);

}
